<form action="${CONTEXT_PATH}/m/apppush/save" method="post" id="push_add" class="form-horizontal">
${token!}
    <input type="hidden" name="m.uuid" value="${m.uuid}"/>
    <div class="form-body">
        <div class="form-group">
            <label class="col-md-3 control-label">推送信息标题</label>
            <div class="col-md-5">
                <input type="text" id="msgtitle" name="m.msgtitle" class="form-control" placeholder="信息标题"
                       value="${m.msgtitle!}">
            </div>
            <span class="status"></span> <#-- 表单校验使用 -->
        </div>
        <div class="form-group">
            <label class="col-md-3 control-label">推送信息内容</label>
            <div class="col-md-5">
                <input type="text" class="form-control" id="msgtext" name="m.msgtext" placeholder="推送内容"
                       value="${m.msgtext!}"/>
            </div>
            <span class="status"></span>
        </div>
        <div class="form-group">
            <label class="col-md-3 control-label">消息类型</label>
            <div class="col-md-5">
                <select class="form-control" id="msgtype" name="m.msgtype">
                    <option value="system">系统消息</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-md-3 control-label">平台</label>
            <div class="col-md-5">
                <select class="form-control" id="platform" name="m.platform">
                    <option value="Android">Android</option>
                    <option value="IOS">IOS</option>
                    <option value="ALL">ALL</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-md-3 control-label">备注</label>
            <div class="col-md-5">
                <textarea rows="3" name="m.remark" class="form-control">${m.remark!}</textarea>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
    jQuery("#push_add").ready(function () {
        // 定义验证参数
        var validateOptions = $.extend(CONST_VALIDATE.OPTION, {
            rules: {
                "m.msgtitle": {
                    required: true,
                    maxlength: 50
                },
                "m.msgtext": {
                    required: true,
                    maxlength: 500
                }
            },
            messages: {
                "m.msgtitle": {
                    required: "<i class='fa fa-exclamation tooltips'></i>请输入消息标题",
                    maxlength: $.validator.format("<i class='fa fa-exclamation tooltips'></i>消息标题不能大于{0}个字符")
                },
                "m.msgtext": {
                    required: "<i class='fa fa-exclamation tooltips'></i>请输入消息内容",
                    maxlength: $.validator.format("<i class='fa fa-exclamation tooltips'></i>消息内容不能大于{0}个字符")
                }
            },
            submitHandler:function(form) {
                var modal = $("#ajax_add");
                $(form).ajaxSubmit(function (data, status, xhr) {
                    if (data.status) {
                        toastr.success(data.msg, '操作提示');
                    } else {
                        toastr.error(data.msg, '操作提示');
                    }
                });
                $(modal).modal('hide');
                dtgrid.load();
            }
        });
        //表单验证
        var validator = $("#push_add").validate(validateOptions);
    });
</script>